package com.github.zxhTom.demo.jol.factory;

public class OnFactory {
    private Integer age=null;
    private static OnFactory onFactory;

    public Integer getAge() {
        return age;
    }

    public static void setInstance() {
        onFactory = null;
    }
    public static OnFactory getInstance() {
        if (null == onFactory) {
            synchronized (OnFactory.class) {
                if (null == onFactory) {
                    //System.out.println("init......");
                    try {
                        Thread.sleep(1);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    onFactory = new OnFactory();
                    onFactory.age=8;
                }
            }
        }
        return onFactory;
    }
}
